<template>
  <div class="page-layout">
    <el-form
      :model="formInline"
      ref="form"
      label-width="90px"
      class="form-inline"
      size="mini"
      label-suffix="："
    >
      <el-row :gutter="2">
        <el-col :lg="6" :xl="4"
          ><el-form-item label="保险公司">
            <el-input
              v-model="formInline.user"
              placeholder="请选择保险公司"
            ></el-input> </el-form-item
        ></el-col>
        <el-col :lg="6" :xl="4"
          ><el-form-item label="保单号">
            <el-input
              v-model="formInline.user"
              placeholder="请输入保单号"
            ></el-input> </el-form-item
        ></el-col>
        <el-col :lg="6" :xl="4"
          ><el-form-item label="车号">
            <el-input
              v-model="formInline.user"
              placeholder="请输入车号"
            ></el-input> </el-form-item
        ></el-col>
        <el-col :lg="6" :xl="4"
          ><el-form-item label="箱号">
            <el-input
              v-model="formInline.user"
              placeholder="请输入箱号"
            ></el-input> </el-form-item
        ></el-col>
        <el-col :lg="6" :xl="4"
          ><el-form-item label="厢号">
            <el-input
              v-model="formInline.user"
              placeholder="请输入厢号"
            ></el-input> </el-form-item
        ></el-col>
        <el-col :lg="6" :xl="4"
          ><el-form-item label="当前节点">
            <el-input
              v-model="formInline.user"
              placeholder="请输入厢号"
            ></el-input> </el-form-item
        ></el-col>

        <el-col v-show="isShow" :lg="8" :xl="6"
          ><el-form-item label="报案时间">
            <el-date-picker
              style="width: 100%"
              v-model="formInline.value1"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            >
            </el-date-picker></el-form-item
        ></el-col>
        <el-col :lg="6" :xl="4"
          ><el-form-item label="运单号">
            <el-input
              v-model="formInline.user"
              placeholder="请输入运单号"
            ></el-input> </el-form-item
        ></el-col>
        <el-col :lg="6" :xl="4"
          ><el-form-item label="赔案状态">
            <el-input
              v-model="formInline.user"
              placeholder="请输入赔案状态"
            ></el-input> </el-form-item
        ></el-col>
        <el-col :lg="1" :xl="1"
          ><el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
          </el-form-item></el-col
        >
      </el-row>
    </el-form>
    <div style="margin-bottom: 12px">
      <el-button type="primary" size="mini">导出</el-button>
    </div>
    <el-table
      size="mini"
      ref="table"
      border
      :data="tableData"
      :height="tableHeight"
      :style="{ width: '100%' }"
    >
      <el-table-column prop="policyNo" label="当前节点" width="150">
      </el-table-column>
      <el-table-column prop="policyNo" label="案件号" width="150">
      </el-table-column>
      <!-- <el-table-column
        prop="tagInvoiceWaybill"
        label="标记发票号码运单号"
        width="220"
      >
      </el-table-column> -->
      <el-table-column prop="goodsName" label="货物" width="120">
      </el-table-column>
      <el-table-column prop="rbReportNumber" label="赔案状态" width="120">
      </el-table-column>
      <el-table-column prop="claimType" label="情况说明" width="300">
      </el-table-column>
      <el-table-column prop="assured" label="未受理原因" width="120">
      </el-table-column>
      <el-table-column prop="currentNode" label="赔付金额" width="120">
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small"
            >查看详情</el-button
          >
          <el-button @click="handleClick(scope.row)" type="text" size="small"
            >跟踪</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      style="margin-top: 10px"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageNum"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
    >
      <el-timeline :reverse="reverse">
        <el-timeline-item
          v-for="(activity, index) in activities"
          :key="index"
          :timestamp="activity.timestamp"
        >
          {{ activity.content }}
        </el-timeline-item>
      </el-timeline>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
  <script>
export default {
  data() {
    return {
      pageSize: 10,
      total: 0,
      pageNum: 1,
      activities: [
        {
          content: "报案",
          timestamp: "2018-04-15",
        },
        {
          content: "立案",
          timestamp: "2018-04-13",
        },
        {
          content: "勘查/定损",
          timestamp: "2018-04-11",
        },
        {
          content: "核赔",
          timestamp: "2018-04-11",
        },
        {
          content: "付款",
          timestamp: "2018-04-11",
        },
        {
          content: "已结案",
          timestamp: "2018-04-11",
        },
      ],
      dialogVisible: false,
      tableHeight: 0,
      isShow: false,
      formInline: {
        user: "",
        region: "",
        value1: "",
      },
      tableData: [],
    };
  },
  methods: {
    trackClick() {},
    more() {
      this.isShow = !this.isShow;
      this.setTableHeight();
    },
    onSubmit() {
      this.pageNum = 1
      this.getTableData()
    },
    handleSizeChange(val) {
      this.pageNum = 1
      this.pageSize = val
      this.getTableData()
    },
    handleCurrentChange(val) {
      this.pageNum = val
      this.getTableData()
    },
    setTableHeight() {
      this.$nextTick(() => {
        const bodyHeight = window.innerHeight;
        const queryHeight = this.$refs.form && this.$refs.form.$el && this.$refs.form.$el.offsetHeight;
        this.tableHeight = bodyHeight - queryHeight - 210 + "px";
      });
    },
    getTableData() {
      const params = {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
      };
      this.$get("/warranty/insure/claim", params).then((res) => {
        if (res) {
          this.tableData = res.rows;
          this.total = res.total;
        } else {
          this.tableData = [];
          this.total = 0;
        }
      });
    },
  },
  mounted() {
    this.setTableHeight();
    window.addEventListener("resize", this.setTableHeight);
    this.getTableData();
  },
};
</script>
  <style scoped lang="less">
.time {
  /deep/.el-form-item__label {
    line-height: 20px;
  }
}
</style>
  